package javango.contrib.jquery.widgets;

import java.util.Map;

import javango.contrib.jquery.JqueryWidget;
import javango.forms.fields.BoundField;
import javango.forms.widgets.DateTimeWidget;
import javango.forms.widgets.DateWidget;

public class JQueryDateTimeWidget extends DateTimeWidget implements JqueryWidget {

	@Override
	public String render(String name, Object value, Map<String, Object> attrs) {
		StringBuilder s = new StringBuilder(super.render(name, value, attrs));
		String javascript = String.format("$('#id_%s\').val(formatDate(new Date(), 'MM/dd/yyyy HH:mm')); return true;", 
				name);
		
		s.append(String.format(" <a href=\"#\" onclick=\"%s\">now</a>", javascript));
		return s.toString();
	}

	public String getScript(BoundField field) {
		return null;
	}
//		// TODO Is this the correct way to grab a field's id?
//		if (field.getField().isEditable()) {
//			return String.format("$(\"#id_%s\").datePicker();", 
//				(String)field.getHtmlName());
//		}
//		return null;
//	}

	
}
